package BinaryTreePackage;

/**
 * @author Lzm
 * @version 1.0
 */
public class findBottomLeftValue_ {
  int maxDepth = 0;
  int result = 0;



  public int findBottomLeftValue(TreeNode root) {
    int maxDepth = 0;
    int result = 0;
    backTracking(root,maxDepth);
    return result;
  }

  public void backTracking(TreeNode root,int Depth){
    if (root.left == null && root.right == null){
      if (Depth > maxDepth){
        maxDepth = Depth;
        result = root.val;
      }
    }
   if (root.left != null){
     Depth ++;
     backTracking(root.left,Depth);
     Depth--;
   }
    if (root.right != null){
      Depth ++;
      backTracking(root.right,Depth);
      Depth--;
    }
  }
}
